import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.InputStreamReader;

import javax.swing.JFileChooser;


public class FileParser {
	
	public FileParser(){
		
		/*
		 * File Chooser
		 */

		final JFileChooser choosingMap = new JFileChooser();
	    final int chooseReturnVal = choosingMap.showOpenDialog(null);
	    //File mapFile = choosingMap.getSelectedFile();

	   if(chooseReturnVal == JFileChooser.APPROVE_OPTION){
		   String fileName = choosingMap.getSelectedFile().getName();
	  
	       /*
	        * Start of file reader
	        */

	       try{
	    	   // Open the file that is the first 
	    	   // command line parameter
	    	   String hostDrive = "J:\\";
	    	   FileInputStream fstream = new FileInputStream(hostDrive+fileName);
	    	    // Get the object of DataInputStream
	    	    DataInputStream in = new DataInputStream(fstream);
	    	        BufferedReader br = new BufferedReader(new InputStreamReader(in));
	    	    String strLine;
	    	    //Read File Line By Line
	    	    while ((strLine = br.readLine()) != null)   {
	    	      // Print the content on the console
	    	      System.out.println (strLine);
	    	      
	    	    }
	    	    //Close the input stream
	    	    in.close();
	    	    }catch (Exception openError){//Catch exception if any
	    	      System.err.println("Error: " + openError.getMessage());
	    	    }
	   		}
	   
	}
}
